
<?php
if (!defined('APP_PATH')) {
	define('APP_PATH', $_SERVER['DOCUMENT_ROOT']."/bdACPA");
}
require_once(APP_PATH.'/required.php');
$message = null;
$dossier = new Dossier();
$dossier->iddossier = intval($_REQUEST['idDossier']);
$dossier->atteint = intval($_REQUEST['atteint']);
$dossier->foetus = intval($_REQUEST['foetus']);
$dossier->idcategoriebiomed = intval($_REQUEST['categorieBiomed']);
$dossier->idcentre = intval($_REQUEST['idCentre']);
$dossier->idmedecin = intval($_REQUEST['medecin']);
$dossier->numero = remove_carspeciaux($_REQUEST['numero']);
$dossier->sexe = $_REQUEST['sexe'];
$dossier->autrephenotype = remove_carspeciaux($_REQUEST['autrephenotype']);

if ($_REQUEST['idDossier'] == null || $_REQUEST['idDossier'] == 0){
	$result = $DOSSIER_DAO->ajouter_dossier($dossier);
} else {
	$result = $DOSSIER_DAO->modifier_dossier($dossier);
} 
$nb_pheno = $PHENOTYPE_DAO->max_idPhenotype();
$PHENOTYPE_DAO->supprimer_phenotype_dossier($result);
for ($i=1 ; $i<$nb_pheno ;$i++){
	if (isset ($_REQUEST['pheno_'.$i]) && intval($_REQUEST['pheno_'.$i])==1){
		$penotypeDossier = new PhenotypeDossier();
		$penotypeDossier->iddossier = $result;
		$penotypeDossier->idphenotype = $i;
		if (isset($_REQUEST['autre_'.$i])){
			$penotypeDossier->precision = remove_carspeciaux($_REQUEST['autre_'.$i]);
		} else {
			$penotypeDossier->precision = null;
		}
		$result2 = $PHENOTYPE_DAO->ajouter_phenotype_dossier($penotypeDossier);
	}
}



unset($dossier);

echo $result;

?>

